import torch
dataset = torch.load('dataset_3.pt',weights_only=False)
print("数据类型:", type(dataset))
print("样本数量:", len(dataset))
# 取一个样本（可修改索引）
sample = dataset[250]
print("样本类型:", type(sample))
print("样本维度:", len(sample))

# 一次性转换并保存（只需运行一次）
new_dataset = []
for src, tgt in dataset:
    src_tensor = torch.tensor(src, dtype=torch.float32) if not isinstance(src, torch.Tensor) else src.float()
    tgt_tensor = torch.tensor(tgt, dtype=torch.float32) if not isinstance(tgt, torch.Tensor) else tgt.float()
    new_dataset.append((src_tensor, tgt_tensor))

torch.save(new_dataset, 'dataset_tensor.pt')
print("Saved as pure Tensor dataset.")